package com.hxzy.authentication.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxzy.authentication.domain.TsEnterpriseCertification;
import com.hxzy.authentication.mapper.TsEnterpriseCertificationMapper;
import com.hxzy.authentication.service.TsEnterpriseCertificationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mingqian.Wu
 * @since 2023-06-23
 */
@Service
@DataSource(value = DataSourceType.AUTHENTICATION)
public class TsEnterpriseCertificationServiceImpl extends ServiceImpl<TsEnterpriseCertificationMapper, TsEnterpriseCertification> implements TsEnterpriseCertificationService {

    @Autowired
    private TsEnterpriseCertificationMapper tsEnterpriseCertificationMapper;

    @Override
    public List<TsEnterpriseCertification> getQueryList(TsEnterpriseCertification tsEnterpriseCertification) {
        QueryWrapper<TsEnterpriseCertification> wrapper=new QueryWrapper<>();
        wrapper.eq(Objects.nonNull(tsEnterpriseCertification.getRegisterPhone()),"register_phone",tsEnterpriseCertification.getRegisterPhone());
        wrapper.eq(Objects.nonNull(tsEnterpriseCertification.getApplyTime()),"apply_time",tsEnterpriseCertification.getApplyTime());
        wrapper.like(Objects.nonNull(tsEnterpriseCertification.getEnterpriseName()),"enterprise_name",tsEnterpriseCertification.getEnterpriseName());
        List<TsEnterpriseCertification> tsEnterpriseCertifications = tsEnterpriseCertificationMapper.selectList(wrapper);
        return tsEnterpriseCertifications;
    }




    @Override
    public  List<TsEnterpriseCertification> getTsEnterpriseCertification() {
        List<TsEnterpriseCertification> tsEnterpriseCertification = tsEnterpriseCertificationMapper.getTsEnterpriseCertification();
        if(tsEnterpriseCertification!=null){
            return  tsEnterpriseCertification;
        }
        return null;
    }

    @Override
    public List<TsEnterpriseCertification> getxqTsEnterpriseCertification(String id) {
//        List<TsEnterpriseCertification> tsEnterpriseCertification1 = tsEnterpriseCertificationMapper.getxqTsEnterpriseCertification(id);
        List<TsEnterpriseCertification> tsEnterpriseCertification1 = new ArrayList<>();
        TsEnterpriseCertification tsEnterpriseCertification = baseMapper.selectById(id);
        tsEnterpriseCertification1.add(tsEnterpriseCertification);
        if(tsEnterpriseCertification!=null){

            return tsEnterpriseCertification1;
        }
        return null;
    }

    @Override
    public TsEnterpriseCertification updatagetxqTsEnterpriseCertification(@PathVariable String id) {
//        TsEnterpriseCertification tsEnterpriseCertification = tsEnterpriseCertificationMapper.updateById(id);
//        if(tsEnterpriseCertification!=null){
//            return tsEnterpriseCertification;
//        }
        return null;

    }

    @Override
    public TsEnterpriseCertification getimageTsEnterpriseCertification(String id) {
        TsEnterpriseCertification tsEnterpriseCertification = tsEnterpriseCertificationMapper.selectById(id);
        if(tsEnterpriseCertification!=null){
            return tsEnterpriseCertification;
        }
        return null;
    }

}
